ActiveAdmin.register AdminUser do
  menu :parent => "Admin"
  permit_params :email, :password, :password_confirmation
  permit_params(abilities_attributes: [:name, :_destroy, :id, :access => []])

  index do
    column :email
    column :current_sign_in_at
    column :last_sign_in_at
    column :sign_in_count
    default_actions
  end

  filter :email

  form do |f|
    f.inputs "Admin Details" do
      f.input :sign_in_count
      f.input :email
      f.input :password
      f.input :password_confirmation
      f.has_many :abilities, :allow_destroy => true, :heading => '权限', :new_record => true do |cf|
        cf.input :name, :collection => %w/post news/
        cf.input :access, as: :check_boxes ,:collection => %w/read create update destroy/
      end
    end
    f.actions
  end

end
